package com.honey.compilation.properties;

import java.util.ArrayList;
import java.util.List;

import com.honey.core.builder.CharacterBuilder;
import com.honey.core.builder.CharacterBuilderFactory;
import com.honey.core.compiler.CompilationException;
import com.honey.core.compiler.IndentSpace;

/**
 * Propertie 文件注释
 * @author Administrator
 *
 */
public class CommentsElement extends PropertieElement  {
	
	/** 注释内容 */
	private List<String> comments;
	
	/**
	 * 构造函数
	 */
	public CommentsElement(){		
		comments = new ArrayList<String>();
	}
	
	/**
	 * 构造函数
	 * @param comments  注释
	 */
	public CommentsElement(String ...comments ){
		this();
		addComment(comments);
	}
	
	/**
	 * 添加注释
	 * @param comments
	 */
	public void addComment(String ...comments){
		for( String comment : comments){
			if(comment !=null){
				this.comments.add(comment);
			}
		}
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.core.dom.properties.PropertieElement#compiledContent()
	 */
	@Override
	public CharacterBuilder compiledContent() throws CompilationException {
		CharacterBuilder answer = CharacterBuilderFactory.createC16StringBuilder();
		for(String comment : comments){
			IndentSpace.newLine(answer);
			answer.append("# ").append(comment);
		}
		return answer;
	}
}	
